<?php
exit;
session_start();
$openid=NULL;
if (isset($_GET['op'])){
    $openid=$_GET['op'];
    $_SESSION['openid']=$openid;
}
if (isset($_SESSION['openid'])){
    $openid=$_SESSION['openid'];
}
if (empty($openid)){
    exit;
}
include_once("./c/config.php");

$userInfo=array();
$name=$phone=$hao=$nianji=$qu=$xuexiao=$xuexiao2=NULL;
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}

$cishu=0;


 
$query=$mysqli->query("select cishu,name,phone,hao from u3 where openid='".$openid."' limit 0, 1");
if($query->num_rows>0){
    	 
    $userInfo=$query->fetch_array();
    $cishu=$userInfo['cishu'];
    $name=$userInfo['name'];
    $phone=$userInfo['phone'];
    $hao=$userInfo['hao'];
  
}
$_SESSION['cishu']=$cishu;
 

$url='http://lin.mei94.com/exam';
$mysqli->close();
?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<title></title>
<style>
html,body{font-size:16px;background:#f6f3ea;width:100%;font-size:12px;color:#fff;font-family:Microsoft YaHei, Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;}
body, div{position:relative;padding:0px;margin:0px auto;max-width:750px;}
.weui-dialog{position:fixed;z-index:5000;width:80%;max-width:300px;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);background-color:#FFF;text-align:center;border-radius:3px;overflow:hidden}.weui-dialog__hd{padding:1.3em 1.6em .5em}.weui-dialog__title{font-weight:400;font-size:18px}.weui-dialog__bd{padding:0 1.6em .8em;min-height:40px;font-size:15px;line-height:1.3;word-wrap:break-word;word-break:break-all;color:#999}.weui-dialog__bd:first-child{padding:1.2em 20px .1em;color:#353535}.weui-dialog__ft{position:relative;line-height:48px;font-size:18px;display:-webkit-box;display:-webkit-flex;display:flex}.weui-dialog__ft:after{content:" ";position:absolute;left:0;top:0;right:0;height:1px;border-top:1px solid #D5D5D6;color:#D5D5D6;-webkit-transform-origin:0 0;transform-origin:0 0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.weui-dialog__btn{display:block;-webkit-box-flex:1;-webkit-flex:1;flex:1;color:#3CC51F;text-decoration:none;-webkit-tap-highlight-color:transparent;position:relative}.weui-dialog__btn:active{background-color:#EEE}.weui-dialog__btn:after{content:" ";position:absolute;left:0;top:0;width:1px;bottom:0;border-left:1px solid #D5D5D6;color:#D5D5D6;-webkit-transform-origin:0 0;transform-origin:0 0;-webkit-transform:scaleX(.5);transform:scaleX(.5)}.weui-dialog__btn:first-child:after{display:none}.weui-dialog__btn_default{color:#353535}.weui-dialog__btn_primary{color:#0BB20C}@media screen and (min-width:1024px){.weui-dialog{width:35%}}.weui-mask{position:fixed;z-index:1000;top:0;right:0;left:0;bottom:0;background:rgba(0,0,0,.6)}.weui-mask_transparent{position:fixed;z-index:1000;top:0;right:0;left:0;bottom:0}
-webkit-touch-callout:none;
-webkit-user-select:none;
html{-ms-touch-action:none;}
*{-webkit-overflow-scrolling:touch;}
.fixfixed {position:absolute;}
div,img{-webkit-tap-highlight-color:rgba(0,0,0,0);}
*{-webkit-text-size-adjust: none;}
.simg{position:absolute;display:block;}
a{text-decoration:none;}
.txt{position:absolute;text-indent:6px;font-size:12px;z-index:2;}
.txt::-webkit-input-placeholder {color:#b4b4b4;text-align:left;}
.container{position:relative;width:100%;height:auto;overflow:hidden;}
.p1, .kai{position:absolute;width:100%;height:100%;display:none;}
.hide{display:none;}
input{position:absolute;display:block;text-indent:10px;-webkit-appearance:none;background:none;padding:0;outline-style:none;border:none;color:#000;}
select{position:absolute;display:block;background:transparent;border:0px;text-indent:8px;font-size:12px;-webkit-appearance:none;}
@-webkit-keyframes p1yu{0%{-webkit-transform:translateX(26px) translateY(-50px);opacity:0;}  80% {-webkit-transform:translateX(0px) translateY(0px);opacity:.9;} 100% {-webkit-transform:translateX(0px) translateY(0px);opacity:1;} }
.p1yu{-webkit-animation: p1yu 4s;}
.t-bg{position:absolute;width:100%;height:100%;background-color:#000;opacity:.9;top:0px;left:0px;display:none;}
.t-bg2{position:absolute;width:100%;height:100%;background-color:#000;opacity:.6;z-index:999;top:0px;left:0px;display:none;}
.t-rule, .t-zhuyi, .ti{position:absolute;width:100%;z-index:99;top:0px;left:0px;display:none;}
.t-end, .t-wan{position:absolute;width:100%;z-index:9999;top:0px;left:0px;display:none;}
.p1-t1{animation-duration:3s;}
 
#iosDialog2{display:none;}
.p1-top{position:absolute;width:100%;display:block;top:0;left:0;}
.p1-di{position:absolute;width:100%;display:block;bottom:0;left:0;}
.p1-button{position:absolute;width:100%;left:0;background:transparent url('<?php echo $url; ?>/img/p1-b.png?v=3') no-repeat;background-size:cover;} 
</style>
</head>
<body>
<div class="container">
  <div class="p1">
     <img class="p1-top simg " src="<?php echo $url; ?>/img/p1.jpg?v=3">
     <img class="p1-di simg " src="<?php echo $url; ?>/img/p1-di.jpg?v=3">
     <div class="p1-button"></div>
  </div>
  <div class="t-bg"></div>
  <div class="kai page">
     <img class="page animated fadeIn simg" src="<?php echo $url; ?>/img/kai-t1.png?v=3">
     <input id="kai-name" class="txt" name="name" type="text" <?php if (!empty($name)){ ?>disabled="disabled"<?php } ?> value="<?php echo  $name; ?>" placeholder="请填写姓名"  />
     <input id="kai-phone" class="txt" name="phone" type="text" <?php if (!empty($phone)){ ?>disabled="disabled"<?php } ?> value="<?php echo  $phone; ?>" placeholder="请填写本人手机号码"  />
  	 <input id="kai-hao" class="txt" name="hao" type="text" <?php if (!empty($hao)){ ?>disabled="disabled"<?php } ?> value="<?php echo  $hao; ?>" placeholder="请填写本人身份证号码"  />
  
     <div class="kai-ks simg"></div>
  </div>

  
  <div class="t-bg2"></div>
  <div class="t-rule">
      
  </div>

  <div class="t-wan">
	<img class="t-wanbg simg" src="<?php echo $url; ?>/img/ti-wan1.png?v=3">
	<div class="t-wclose simg"></div>
  </div>

  <div class="js_dialog" id="iosDialog2" style="opacity: 1;">
       <div class="weui-mask"></div>
       <div class="weui-dialog">
                <div class="weui-dialog__bd weui-msg"></div>
                <div class="weui-dialog__ft">
                    <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary weui-btn">知道了</a>
                </div>
        </div>
 </div>
  
</div>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="<?php echo $url; ?>/js/pxloader-images.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
h= Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
var sWidth = parseInt((window.innerWidth > 0) ? window.innerWidth : screen.width);
if(sWidth>750){sWidth=750;}
var _rate=(sWidth/750);
if(h<_rate*1206){
	h=_rate*1206;
}
var _img=['p1-t2.jpg'];
var loader = new PxLoader();
for(var i=0; i<_img.length; i++){loader.addImage('<?php echo $url; ?>/img/'+_img[i]);}
function setShow(time, id, docall) {
    setTimeout(function () {
        document.querySelector(id).style.display = "block";
        setTimeout(function () {
            if (docall) {
                docall(document.querySelector(id));
            } else {
                document.querySelector(id).style["-webkit-transform"] = "scale(1,1)";
            }
        }, 100);
    }, time);
}
loader.start();
loader.addCompletionListener(function(e) {
     $(".p1").show();
      
     
});

function fixScroll(){
    let u = navigator.userAgent;
    let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    if (isiOS) {
      window.scrollTo(0, 0);
    }
 }
$("input, select").blur(function(){
	fixScroll()
});

$(function(){
	$('.container').width(sWidth).height(h);
	$('.page, .p1-bg, .rule-t1').width(sWidth).height(_rate*1206);

	
 
	$('.p1-t1').width(_rate*296).height(_rate*268).css({"top":0, "right":0});
	$('.p1-t2').width(_rate*111).height(_rate*109).css({"top":_rate*82, "left":_rate*180});
	$('.p1-gui').width(_rate*160).height(_rate*152).css({"top":_rate*89, "left":_rate*336});
	$('.p1-guan').width(_rate*123).height(_rate*119).css({"top":_rate*244, "left":_rate*370});
	$('.p1-sao').width(_rate*118).height(_rate*131).css({"top":_rate*270, "left":_rate*254});
	$('.p1-nian').width(_rate*171).height(_rate*174).css({"top":_rate*354, "left":_rate*272});
	$('.p1-rule').width(_rate*110).height(_rate*120).css({"top":_rate*8, "right":_rate*76});
	 
	$('.p1-button').width(_rate*475).height(_rate*112).css({"top":_rate*650, "left":_rate*137});
 
	$(".rule-body").width(_rate*660).height(_rate*760).css({"top":_rate*90, "left":_rate*47});
	$(".rule-txt").width(_rate*640).css({"top":_rate*0, "left":0});
	$("#kai-name").width(_rate*372).height(_rate*80).css({"top":_rate*260, "left":_rate*278});
	$("#kai-phone").width(_rate*372).height(_rate*80).css({"top":_rate*386, "left":_rate*278});
	$("#kai-hao").width(_rate*372).height(_rate*80).css({"top":_rate*526, "left":_rate*278});
	


	$(".kai-ks").width(_rate*460).height(_rate*96).css({"top":_rate*742, "left":_rate*140});
	$('.zhuyi-t1').width(sWidth).height(_rate*1206).css({"top":0, "left":0});
	$(".zhuyi-body").width(_rate*608).height(_rate*568).css({"top":_rate*218, "left":_rate*72});
	$(".zhuyi-txt").width(_rate*599).css({"top":_rate*0, "left":0});
	$(".zhuyi-t2").width(_rate*450).height(_rate*82).css({"top":_rate*976, "left":_rate*148});

	
	$('.rule-qd').width(_rate*480).height(_rate*84).css({"top":_rate*1026, "left":_rate*130});

	$(".t-wanbg").width(_rate*490).height(_rate*457).css({"top":_rate*200, "left":_rate*130});
	$(".t-wclose").width(_rate*270).height(_rate*80).css({"top":_rate*494, "left":_rate*240});


	if(h > _rate*1206){
		   var _cha= h - _rate*1246;
		   if(_cha > 0){
			  $('.p1-button').css({"top":_rate*650 + _cha/2});
		      $('.kai, .t-wan, .t-rule').css({"top":_cha/2});
		      
		   }
    }
	
	function checkTel(tel){
	    return /^1(3|4|5|6|7|8|9)[0-9]\d{8}$/.test(tel)
	} 
	$(".kai-ks").click(function(){
		 var _name=$("#kai-name").val();
		 var _phone=$("#kai-phone").val();
		 var _hao=$("#kai-hao").val();
		 
         if('' == _name){
             $(".weui-msg").html("请填写学生姓名");
             $("#iosDialog2").show();
             return;
         }
         if('' == _phone){
             $(".weui-msg").html("请填写家长电话");
             $("#iosDialog2").show();
             return;
         }
   
         
         if(false == checkTel(_phone)){
 			$(".weui-msg").html("请输入正确的手机号");
            $("#iosDialog2").show();
            return;
         }
         if('' == _hao){
             $(".weui-msg").html("请填写学生证");
             $("#iosDialog2").show();
             return;
         } 
       
         $.post("api/?c=bao", {name:_name,phone:_phone,hao:_hao}, function(data){
		      <?php if ($cishu>0){ ?>
               $(".t-wan, .t-bg2").show();
               return;
		     <?php }else{ ?>
		     window.location.href="ti.php";
 			 <?php } ?>
 	     }, "json"); 
         
	});

	 
	
	$(".t-wclose").click(function(){
		$(".t-wan, .t-bg2, .t-bg, .kai").hide();
		$(".p1").show();
	});
	$(".weui-btn").click(function(){
        $("#iosDialog2").hide();
	});

 
	$('.p1-button').click(function(){
		//$('.t-rule, .t-bg').fadeIn(); 
		$('.kai, .t-bg').fadeIn();
	});
	$('.t-rule').click(function(){
		$('.t-rule, .t-bg').fadeOut();
	});
	$('.zhuyi-t2').click(function(){
		$('.t-zhuyi, .t-bg').hide();
		window.location.href="ti.php";
	});

	var _thequ=[<?php 
	 $quData=json_decode(file_get_contents('./c/qu.txt'));
	 $html='';
	 foreach($quData as $v){
	 	$html.="'".$v."',";	
	 }
	 echo trim($html,',');
	 ?>];



	if(!('placeholder' in document.createElement('input')) ){   
	    $('input[placeholder],textarea[placeholder]').each(function(){var that = $(this),text= that.attr('placeholder');   
	      if(that.val()===""){that.val(text).addClass('placeholder');}   
	      that.focus(function(){if(that.val()===text){that.val("").removeClass('placeholder');}})   
	      .blur(function(){if(that.val()===""){that.val(text).addClass('placeholder');}})   
	      .closest('form').submit(function(){   
	        if(that.val() === text){that.val('');}});});   
	 }

 
    
});
</script>
</body>
</html>